//
//  UtilsMacros.h
//  MapDemo
//
//  Created by cqck on 2017/7/7.
//  Copyright © 2017年 cqck. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "font.h"
#import "color.h"

#pragma mark - -------数据验证-------
#define kValidStr(o)         (o != nil && [o isKindOfClass:[NSString class]] && ![o isEqualToString:@""])
#define kValidArray(o)       (o != nil && [o isKindOfClass:[NSArray class]])
#define kValidDictionary(o)  (o != nil && [o isKindOfClass:(NSDictionary class)])

#pragma mark - -------GCD-------
#define kGCD_Async_block(block)  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define kGCD_Main_block(block)   dispatch_async(dispatch_get_main_queue(), block)
#define kGCD_Once_block(block)   static dispatch_once_t onceToken;dispatch_once(&onceToken, block)

#pragma mark - -------获取系统对象-------
#define kApplication         [UIApplication sharedApplication]
#define kAppDelegate         [AppDelegate shareAppDelegate]
#define kAppWindow           [UIApplication sharedApplication].delegate.window
#define kUserDefault         [NSUserDefaults standardUserDefaults]
#define kNotificationCenter  [NSNotificationCenter defaultCenter]
#define kFileManager         [NSFileManager defatulManager]
#define kAppVersion          [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
#define kAppBuildVersion     [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define kBundleIdentifier    [[NSBundle mainBundle] bundleIdentifier]
#define kDocumentPath        [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
#define kDocumentCachePath   [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
#define kScreenFrame         [UIScreen mainScreen].bounds
#define kScreenScale         [[UIScreen mainScreen] scale]
#define kStatusbarSize       [[UIApplication sharedApplication] statusBarFrame].size
#define kSystemVersion       [[UIDevice currentDevice].systemVersion floatValue]
#define kIs_iphone           (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define kIs_iPhoneX          CGRectGetWidth(kAppWindow.frame) >=375.0f && CGRectGetHeight(kAppWindow.frame) >=812.0f && kIs_iphone
#define kTabBarHeight        (CGFloat)(kIs_iPhoneX?(34.0):(0.0))

#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
#define oldIDE 0
#define villageVersion 0
#define newBankOpt 1
#define openAllBlance 1 //是否打开所有余额功能
#define newCardService 1 //是否启用新的IC卡服务首页模块
#define openNFCUI 0

#pragma mark - -------获取系统字体-------
#define kSystemFont(fontSize)      [UIFont systemFontOfSize:fontSize]
#define kSystemNewsFont(fontSize)      [UIFont systemFontOfSize:fontSize + 3]
#define kBlodSystemFont(fontSize)  [UIFont boldSystemFontOfSize:fontSize]
#define kFont(name, fontSize)      [UIFont fontWithName:name size:fontSize]

#pragma mark - -------弱、强引用定义-------
#ifndef kWeakify
#define kWeakify(obj) autoreleasepool{} __weak __typeof__(obj) weak##_##obj = obj
#endif

#ifndef kStrongify
#define kStrongify(obj) try{} @finally{} __typeof__(weak##_##obj) obj = weak##_##obj
#endif

#pragma mark - -------日志定义-------
#ifdef DEBUG
#define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s \n %s\n\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
#else
#define NSLog(...)
#endif

#pragma mark - -------系统日志定义-------
#ifdef DEBUG
#define SLog(...) fprintf(stderr, "%s\n", [[NSString stringWithFormat:__VA_ARGS__] UTF8String])
#else
#define SLog(...)
#endif

extern NSString *const VIColor;
extern NSString *const kViewBackgroundColor;
extern NSString *const kUnPayOrFailTextColor;
extern NSString *const kPaySuccessTextColor;
extern NSString *const kPayingTextColor;
extern NSString *const kOpenHandleURLNotification;
extern NSString *const kFeeNotification;

static NSString *const kUserInfo = @"userInfo";
static NSString *const kSecurityTypeKey = @"SecurityType";
//static NSString *const kUpdateUserInfoKey = @"updateUserInfo";

#define TIME_STAMP [[NSDate date] stringWithFormat:@"yyyyMMddHHmmss"]
#define HEXCOLOR(a) [UtilsMacros hexColor:[NSString stringWithFormat:@"#%@", a]]
#define IMAGENAME(a) [UIImage imageNamed:a]
#define RGBCOLOR( r , g , b ) [UIColor colorWithRed:( r )/255.f green:( g )/255.f blue:( b )/255.f alpha:1.0]
#define SCREENW [UIScreen mainScreen].bounds.size.width
#define SCREENH [UIScreen mainScreen].bounds.size.height

typedef NS_ENUM(NSUInteger, CellStyle) {
    SingleCell,
    MiddleCell,
    BottomCell,
    TopCell,
};

typedef NS_ENUM(NSUInteger, JYTURLTYPE) {
    JYTURLTYPEHELP = 0,
    JYTURLTYPEDOT1,
    JYTURLTYPEDOT2,
    JYTURLTYPECARD,
    JYTURLTYPENEWS,
    JYTURLTYPECARDMANAGER,
    JYTURLTYPELOSTCARD,
    JYTURLTYPECARDBLANCE,
    JYTURLTYPESHOP,
    JYTURLTYPESHUPHUI,
};

typedef NS_ENUM(NSUInteger, QPHomeTableHeaderBtnType) {
    QPHomeTableHeaderBtnTypeBind,
    QPHomeTableHeaderBtnTypeNetSearch,
    QPHomeTableHeaderBtnTypeQuanSearch,
    QPHomeTableHeaderBtnTypeCardExplain,
    QPHomeTableHeaderBtnTypeMyCard,
    QPHomeTableHeaderBtnTypeIssue,
    QPHomeTableHeaderBtnTypeBalanceSearch,
    QPHomeTableHeaderBtnTypeCardCharge,
    QPHomeTableHeaderBtnTypeChangeLocation,
    QPHomeTableHeaderBtnTypeQR,
};

typedef NS_ENUM(NSUInteger, ProtocolType) {
    ProtocolTypeUserRegister,//注册协议
    ProtocolTypeCharge,//充值协议
    ProtocolTypeAccount,//电子钱包协议
    ProtocolTypeOnlineCard,//云公交卡协议
    ProtocolTypeBindCard,//快捷支付(绑卡)协议
    ProtocolTypeHelp,//支付管理中心帮助
};

typedef NS_ENUM(NSUInteger, TravelListType) {
    TravelListTypeRecruit = 1,
    TravelListTypeHistory,
    TravelListTypeJoined,
    TravelListTypeMyLaunched,
};

typedef NS_ENUM(NSUInteger, PublishStatus) {
    PublishStatusWait = 1,
    PublishStatusPass,
    PublishStatusReject,
};

typedef NS_ENUM(NSUInteger, CellType) {
    CellTypePay,
    CellTypeNoPay,
    CellTypeProgressStatus,
    CellTypeRejectStatus,
    CellTypeCancelStatus,
    CellTypeInvalidStatus,
    CellTypeNone = 9999,
};

typedef NS_ENUM(NSUInteger, InputType) {
    InputTypeStr,
    InputTypeId,
    InputTypeNumber,
};

typedef NS_ENUM(NSUInteger, ImagePickType) {
    ImagePickTypeBoth,
    ImagePickTypeAlbum,
    ImagePickTypeCamera,
};
//出有拼巴订单类型
typedef NS_ENUM(NSUInteger, OrderActionType) {
    OrderActionTypeStay,
    OrderActionTypePay,
    OrderActionTypeFinish,
};

//订单业务类型
typedef NS_ENUM(NSUInteger, OrderBizType) {
    OrderBizTypeTravel,
    OrderBizTypeVillage,
    OrderBizTypeAll,
};

//出游拼巴已完成订单类型枚举
typedef NS_ENUM(NSUInteger, FinishOrderStatus) {
    FinishOrderStatusRefundApplying = 1,
    FinishOrderStatusRefundApplyReject = 2    ,
    FinishOrderStatusRefunded = 3,
    FinishOrderStatusOverdue = 4,
    FinishOrderStatusFinish = 5,
    FinishOrderStatusRefunding = 6,
    FinishOrderStatusNone = 99,
};

typedef void(^ImagePickCallback)(void);

@interface UtilsMacros : NSObject

+ (instancetype)sharedInstance;

+ (void)saveCacheObj:(id)obj key:(NSString *)key;

+ (void)removeCacheWithKey:(NSString *)key;

+ (id)cacheObjWityKey:(NSString *)key;

+ (void)uSSZipArchiveWithFilePath:(NSString *)path destinationPath:(NSString *)destinationPath;

+ (UIColor *)hexColor:(NSString *)hexColor;

@end
